import 'package:flutter/material.dart';
import 'package:shopping_list/global.dart';

class Item extends StatefulWidget {
  Item({
    Key key,
    this.title,
    this.text,
    this.hintText,
    this.onTap,
  }) : super(key: key);
  final String title;
  final String hintText;
  final String text;
  final onTap;

  @override
  State<StatefulWidget> createState() => _ItemState();
}

class _ItemState extends State<Item> {
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
      width: MediaQuery.of(context).size.width,
      height: 50,
      decoration: BoxDecoration(
        color: Global.backgroundColor,
        border: Border(
          bottom: BorderSide(
            color: Global.fontSecondColor.withOpacity(0.2),
            width: 1,
            style: BorderStyle.solid,
          ),
        ),
      ),
      child: Row(
        children: [
          Text(
            "${widget.title}：",
            style: TextStyle(
              fontSize: 16,
              color: Global.fontColor,
            ),
          ),
          Expanded(
            child: InkWell(
              onTap: widget.onTap,
              child: Text(
                "${widget.text ?? widget.hintText}",
                textAlign: TextAlign.end,
                style: TextStyle(
                  fontSize: 16,
                  color: widget.text == null
                      ? Global.fontSecondColor
                      : Global.fontColor,
                ),
              ),
            ),
          ),
          Icon(
            Icons.chevron_right,
            color: Global.fontSecondColor,
          )
        ],
      ),
    );
  }
}
